package com.zlcx.tz.live.repository;

import com.zlcx.tz.live.domain.ApiRequestStatisticsDO;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Lock;
import org.springframework.stereotype.Repository;

import javax.persistence.LockModeType;

/**
 * @author anjl
 */
@Repository
public interface ApiRequestStatisticsRepository extends JpaRepository<ApiRequestStatisticsDO, Long>, JpaSpecificationExecutor<ApiRequestStatisticsDO> {
    ApiRequestStatisticsDO findByDayAndMethodAndUrl(String today, String method, String url);

    @Lock(value = LockModeType.PESSIMISTIC_WRITE)
    ApiRequestStatisticsDO findById(Long id);

}
